/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bjtu.lms.service.impl;

import com.bjtu.lms.dao.AdminDao;
import com.bjtu.lms.model.Administrator;
import com.bjtu.lms.service.AdminService;

/**
 *
 * @author yilee
 */
public class AdminServiceImpl implements AdminService {

	private AdminDao adminDao;

	public AdminDao getAdminDao() {
		return adminDao;
	}

	public void setAdminDao(AdminDao adminDao) {
		this.adminDao = adminDao;
	}

	public Administrator login(String username, String password) {
		Administrator a = findAdminByUsername(username);
		if (a == null) {
			return null;
		} else {
			if (a.getPassword().equals(password)) {
				return a;
			} else {
				return null;
			}
		}
	}

	public Administrator findAdminById(int id) {
		return adminDao.findAdminById(id);
	}

	public Administrator findAdminByUsername(String username) {
		return adminDao.findAdminByUserName(username);
	}
}
